Skip to content

Support async bundling with JS resolver#263

Merged
devongovett merged 4 commits intomasterfrom
bundle-resolver
Sep 4, 2022
Merged

Support async bundling with JS resolver#263
devongovett merged 4 commits intomasterfrom
bundle-resolver

Conversation

@devongovett
Copy link
Member

This is an alternative approach to #196. This approach doesn't require converting the whole bundler to async. Instead, it uses napi threadsafe functions in combination with channels to wait for the result from the JavaScript thread in the rayon thread.

This required a fork of threadsafe_function.rs from napi-rs to support getting the result of the JS function, which I hope to potentially contribute upstream. This also means there is no required JS wrapper to convert from a callback-based API to a promise-based one.

Still need to do some performance testing to see generally how much a JS resolver slows things down.

cc. @dgp1130

@devongovett
Copy link
Member Author

Basic performance testing indicates that using a resolver with fs.readFileSync is about 15% slower than native, and using fs.promises.readFile is about 40% slower.

@devongovett devongovett marked this pull request as ready for review September 3, 2022 23:51
@devongovett devongovett merged commit e3ad301 into master Sep 4, 2022
@devongovett devongovett deleted the bundle-resolver branch September 4, 2022 00:17
@dgp1130
Copy link
Contributor

dgp1130 commented Sep 6, 2022

Very cool stuff! Excited to play around with this implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants